]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensions-tool: Add --template create option
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 7 Nov 2019 11:46:47 +0000 (12:46 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 7 Apr 2020 20:27:00 +0000 (20:27 +0000)
We now have everything in place to allow users to pick a template
other than the default one (although at the moment it's the only
one we have), so add a corresponding option.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/812

subprojects/extensions-tool/completion/bash/gnome-extensions
subprojects/extensions-tool/man/gnome-extensions.txt
subprojects/extensions-tool/src/command-create.c

index 9630ce9d77272d1e8c87bc95124cebca98e1274b..05cd039269a5920cf4821118cd9413b3706641ea 100644 (file)
@@ -44,6 +44,14 @@ __gnome_extensions() {
   esac
 
   case "$COMMAND" in
+    create)
+      case "$prev" in
+        --template)
+          COMPREPLY=($(compgen -W "`gnome-extensions create --list-templates`" -- "$2"))
+          return 0
+          ;;
+      esac
+      ;;
     pack)
       case "$prev" in
         --podir|--out-dir|-o)
index d94c0bd2e3d50979edc8800edddbb73392c92ebb..adc08e97a2e523d13f7eb596921949018c54e820 100644 (file)
@@ -128,6 +128,9 @@ Creates a new extension from a template.
   *--uuid*='UUID':::
     Set the unique extension ID in the metadata to 'UUID'
 
+  *--template*='TEMPLATE':::
+    Use 'TEMPLATE' as base for the new extension
+
   *-i*:::
   *--interactive*:::
     Prompt for any extension metadata that hasn't been provided
index d51d4dac64493785c5d92d3bbaa8d66d4579c150..37a3118bce93d690f4525670e9d5491b712dc3bc 100644 (file)
@@ -208,11 +208,14 @@ launch_extension_source (GFile *dir, GError **error)
 }
 
 static gboolean
-create_extension (const char *uuid, const char *name, const char *description)
+create_extension (const char *uuid, const char *name, const char *description, const char *template)
 {
   g_autoptr (GFile) dir = NULL;
   g_autoptr (GError) error = NULL;
 
+  if (template == NULL)
+    template = "plain";
+
   dir = g_file_new_build_filename (g_get_user_data_dir (),
                                    "gnome-shell",
                                    "extensions",
@@ -231,7 +234,7 @@ create_extension (const char *uuid, const char *name, const char *description)
       return FALSE;
     }
 
-  if (!copy_extension_template ("plain", dir, &error))
+  if (!copy_extension_template (template, dir, &error))
     {
       g_printerr ("%s\n", error->message);
       return FALSE;
@@ -328,6 +331,7 @@ handle_create (int argc, char *argv[], gboolean do_help)
   g_autofree char *name = NULL;
   g_autofree char *description = NULL;
   g_autofree char *uuid = NULL;
+  g_autofree char *template = NULL;
   gboolean interactive = FALSE;
   gboolean list_templates = FALSE;
   GOptionEntry entries[] = {
@@ -343,6 +347,10 @@ handle_create (int argc, char *argv[], gboolean do_help)
       .arg_description = _("DESCRIPTION"),
       .arg = G_OPTION_ARG_STRING, .arg_data = &description,
       .description = _("A short description of what the extension does") },
+    { .long_name = "template",
+      .arg = G_OPTION_ARG_STRING, .arg_data = &template,
+      .arg_description = _("TEMPLATE"),
+      .description = _("The template to use for the new extension") },
     { .long_name = "list-templates",
       .arg = G_OPTION_ARG_NONE, .arg_data = &list_templates,
       .flags = G_OPTION_FLAG_HIDDEN },
@@ -403,5 +411,5 @@ handle_create (int argc, char *argv[], gboolean do_help)
       return 1;
     }
 
-  return create_extension (uuid, name, description) ? 0 : 2;
+  return create_extension (uuid, name, description, template) ? 0 : 2;
 }